package com.lqw.wechat.app.config;

import com.alibaba.druid.pool.DruidDataSource;
import com.lqw.wechat.common.config.WeChatAccessConfig;
import com.lqw.wechat.common.config.WeChatRequestConfig;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.sql.DataSource;
import java.sql.SQLException;

/**
 * Created by luqiwen on 2017/7/27.
 */
@Configuration
public class SpringBeanBuild {

    private static final Logger LOGGER= LoggerFactory.getLogger(SpringBeanBuild.class);

    @Bean(value = "weChatAccessConfig")
    @ConfigurationProperties(prefix="wechat.access")
    public WeChatAccessConfig weChatAccessConfig(){
        return new WeChatAccessConfig();
    }

    @Bean(value = "weChatRequestConfig")
    @ConfigurationProperties(prefix="wechat.access.url")
    public WeChatRequestConfig weChatRequestConfig(){
        return new WeChatRequestConfig();
    }

    @Bean(value = "dataSource")
    @ConfigurationProperties(prefix="spring.datasource")
    public DataSource dataSource() {
        return  new DruidDataSource();
    }

}
